/*
 * errorDisplayGUI.java
 *
 * Created on 24 de Dezembro de 2008, 04:16
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package trigger.utils;

import java.io.IOException;
import java.io.OutputStream;
import trigger.gui.ErrorShowGUI;

/**
 *
 * @author vinicius
 */
public class ErrorDisplay extends OutputStream{

    private ErrorShowGUI errorshowgui;
    private ShowerThread shower;
    private StringBuffer sb;
    
    public ErrorDisplay(ErrorShowGUI errorshowgui){
        this.errorshowgui = errorshowgui;
        sb = new StringBuffer();
        shower = new ShowerThread(errorshowgui);
    }
    
    public synchronized void write(byte b[], int off, int len) {
        sb.append(new String(b,off,len));
    }

    public synchronized void flush(){
        if(!shower.isShow()){
            shower.setShow(true);
            java.awt.EventQueue.invokeLater(shower);
        }
        errorshowgui.flush(sb.toString());
        sb.delete(0,sb.length());
    }        
    
    public void write(int b) throws IOException {
    }
    
                   
    
}